package edu.sctu.lab03;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class loginServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String username=req.getParameter("username");
        String password=req.getParameter("password");
        PrintWriter out=resp.getWriter();
        if ("admin".equals(username)&&"123456".equals(password)){
            out.write("登录成功");
            req.setAttribute("isLogin","true");
            resp.sendRedirect("userList.jsp");
        }else {
            out.write("登录失败，用户名或密码错误");
        }
        req.getRequestDispatcher("/login.jsp").forward(req,resp);
    }
}
